<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<jsp:useBean id="bean" class="com.lmpop.frame.util.RandomID" scope="page" />
<%@ page import="com.lmpop.trade.ts_role.*" %>
<%@ page import="com.lmpop.trade.ti_roleright.*" %>
<%
	request.setCharacterEncoding("UTF-8");
	String cust_id = "000000000000000";	
	if( session.getAttribute("session_cust_id") != null ){
		cust_id = session.getAttribute("session_cust_id").toString();
	}
	String flag = "0";// 0 = add 1 = update 
	if (request.getParameter("flag") != null) {
		flag = request.getParameter("flag");
	}
  
	String name = "新增";
	if(flag.equals("1")){
		name = "修改";
	}
	String role_code = bean.GenTradeId();
	if (request.getParameter("role_code") != null) {
		role_code = request.getParameter("role_code");
	}
	String checked_menu_id = "";

	Ts_roleInfo ts_roleInfo = new Ts_roleInfo();
	Ti_rolerightInfo ti_rolerightInfo = new Ti_rolerightInfo();
	
	List roleList = ts_roleInfo.getRoleInfoByCode(cust_id,role_code);
	List rolerightList = ti_rolerightInfo.getRoleRightInfoByRole(cust_id,role_code);
	
	//Role of the corresponding string of permissions menu fight
	if(rolerightList != null && rolerightList.size() > 0){   
		for(int i=0;i<rolerightList.size();i++){
			Hashtable menuMap = (Hashtable)rolerightList.get(i);
			if(menuMap.get("menu_id")!=null){
				checked_menu_id = menuMap.get("menu_id").toString() + "," + checked_menu_id;
			}
		}
	}
	
	String role_name1="",remark1="";
				
	if(roleList!=null && roleList.size()>0){
		Hashtable map=(Hashtable)roleList.get(0);
		if(map.get("remark")!=null){
			remark1 = map.get("remark").toString();
		}
		if(map.get("role_name")!=null){
			role_name1 = map.get("role_name").toString();
		}
		
	}
	String s_title = "";
	if(request.getParameter("s_title")!=null && !request.getParameter("s_title").equals("")){
		s_title = request.getParameter("s_title");
	}
	String iStart = "0";
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	String para = "s_title="+s_title+"&iStart="+Integer.parseInt(iStart);
%>
<html>
  <head>
    <title><%=name%>角色</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="/js/jquery.js"></script>
		<script type="text/javascript" src="role.js" charset="UTF-8"></script>
		<script type="text/javascript" src="/program/admin/js/judgment.js" charset="UTF-8"></script>
		
</head>

<body>
	<h1><%=name%>角色</h1>
	<!--table width="100%" align="center" cellpadding="0" cellspacing="0" class="dl_so">
        <tr>
          <td width="9%" align="center"><img src="/program/admin/index/images/ban_01.gif" /></td>
          <td width="91%" align="left">
		  <h4>您可以按“行业”或“关键字”订阅</h4>
		  <span>1、填写关键字，您将及时了解与该产品相关的所有商机。</span><br/>
		  <span>2、为了更准确订阅，建议你选择产品所属的行业大类和行业子类。</span>
		  </td>
        </tr>
      </table-->
	<form action="/doTradeReg.do" method="post" name="addForm">
	
	<table width="100%" cellpadding="1" cellspacing="1" border="0" class="listtab">
		
		<tr>
			<td align="right" width="15%">
				角色名称<font color="red">*</font>
			</td>
			<td><input name="role_name" id="role_name" type="text" value="<%=role_name1%>" maxlength="25" onkeyup="inputNoHorns(this)"   onbeforepaste= "inputNoHorns(this); " /></td>
		</tr>
		
		<tr>
			<td align="right" width="15%">
				菜单权限选择<font color="red">*</font>
			</td>
			<td><div id="menu"><img src=/program/admin/images/wait.gif border=0><font size=2>加载中 . . .</font></div></td>
		</tr>
		
		<tr>
			<td align="right" width="15%">
				备注:
			</td>
			<td><input name="remark" id="remark" type="text" size="35" value="<%=remark1%>" maxlength="25" onkeyup="inputNoHorns(this)"   onbeforepaste= "inputNoHorns(this); " /></td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="center">
				<%
					if(flag.equals("0")){
				%>
				<input type="hidden" name="bpm_id" value="9720" />
				<%
					}
				%>
				<%
					if(flag.equals("1")){
				%>
				<input type="hidden" name="bpm_id" value="7896" />
				<%
					}
				%>
				<input type="hidden" name="menu_id" id="menu_id" value=""/>
				<input name="flag" id="flag" type="hidden" value="<%=flag%>" />
				<input name="role_code" id="role_code" type="hidden" value="<%=role_code%>" />
				<input name="cust_id" id="cust_id" type="hidden"  value=<%=cust_id%> />
				<input name="checked_menu_id" id="checked_menu_id" type="hidden"  value=<%=checked_menu_id%> />
				<input type="hidden" name="jumpurl" value="/program/admin/role/index.jsp?<%=para%>" />
				<input class="buttoncss" type="button" name="tradeSub" value="提交" onclick="return tijao()" />&nbsp;&nbsp;
				<input class="buttoncss" type="button" name="tradeRut" value="返回" onclick="window.location.href='index.jsp?<%=para%>';"/>
			</td>
		</tr>
	</table>
	</form>
</body>

</html>
<script type="text/javascript" src="addrole.js"></script>